<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<head>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/dateSelector.js"></script>
    <script src="${pageContext.request.contextPath}/js/landRegistration/landPermits.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            validateLandPermitDetails();

        });

        function validateLandPermitDetails() {
            $('#issueDate').rules("add", {
                isDateFormated: true,
                isFeatureDate: true,
                messages: {
                    ageValidate: $('#pls_enter_valid_age').val()}
            });
        }


        function initialValidate() {
            initialPermits();
        }

        function detailValidate() {
            //detailPermits();
        }

        function showViolationComment() {
            $('#violationComment').show();
        }

        function hideViolationComment() {
            $('#violationComment').hide();
            $('#conditionsViolationComment').val('');
        }

        function violationCommentClick() {
            if ($('#conditionsViolatedOrNot0').is(':checked')) {
                hideViolationComment();
            } else {
                showViolationComment();
            }
        }


    </script>
    <script type="text/javascript">
        function disableFields() {
            var fields = new Array(
                    'referenceNo',
                    'issueDate',
                    'permittedLandUsageId',
                    'currentLandUsageId',
                    'developmentState',
                    'conditionsViolatedOrNot0',
                    'conditionsViolatedOrNot1',
                    'conditionsViolationComment'
            );
            enableFields(fields);
        }

        $(function () {
            if ($('#approvalState').val() == 'PENDING' && (  (  ($('#userRole').val() == 'ORDS') ) || (  ($('#editMode').val() != 1) && ($('#userRole').val() == 'ORIP')   ) )) {
                disableFields();
            }

            if ($('#landMode').val() == 'DETAIL') {
                violationCommentClick();
            } else {
                hideViolationComment();
            }

        });
    </script>
</head>
<div id="tabs">
    <ul>
        <li><s:a href="#land-permit-details"><s:label
                value="%{getText('land_permit_details.label')}"/></s:a></li>
        <li><s:a href="#personal-details"><s:label value="%{getText('holder_details.label')}"/></s:a></li>
        <li><s:a href="#occupier-details"><s:label value="%{getText('occupier_details.label')}"/></s:a></li>
    </ul>
    <div id="land-permit-details">
        <table class="width-100">
            <tr>
                <td><s:label value="%{getText('permit_no.label')}"/><span class="mandatory-field"></span></td>
                <td><s:textfield id="referenceNo" name="alienation.referenceNo" cssClass="width-200-px"/></td>
                <td><s:label value="%{getText('issue_date.label')}"/> <s:label value="%{getText('date_format.label')}"
                                                                               cssClass="date-format"/></td>
                <td><s:textfield id="issueDate" name="alienation.issueDate" onclick="selectDate('issueDate')"
                                 cssClass="width-200-px" onKeyPress="return dateNumbersOnly(event,true)"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('permitted_usage.label')}"/></td>
                <td colspan="3"><s:select id="permittedLandUsageId" name="alienation.permittedUsage.id"
                                          list="landUsageList" headerKey="0" cssClass="width-200-px"
                                          headerValue="%{getText('select.label')}"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('present_usage.label')}"/></td>
                <td colspan="3"><s:select id="currentLandUsageId" name="alienation.currentLandUsage.id"
                                          list="landUsageList" headerKey="0" cssClass="width-200-px"
                                          headerValue="%{getText('select.label')}"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('developed_status.label')}"/></td>
                <td colspan="3" class="left-align"><s:textarea id="developmentState" rows="1"
                                                               name="alienation.developmentState"
                                                               cssClass="width-595-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('conditionsViolatedOrNot.label')}"/></td>
                <td colspan="2"><s:radio id="conditionsViolatedOrNot" name="alienation.conditionsViolatedOrNot"
                                         list="#@java.util.HashMap@{'1':getText('yes.label'),'0':getText('no.label')}"
                                         onclick="violationCommentClick()"/></td>
            </tr>
            <tr id="violationComment">
                <td><s:label value="%{getText('conditionsViolationComment.label')}"/></td>
                <td colspan="3"><s:textarea id="conditionsViolationComment" name="alienation.conditionsViolationComment"
                                            rows="1"
                                            cssClass="width-595-px"/></td>
            </tr>
        </table>
    </div>
    <div id="personal-details">
        <table class="width-100">
            <s:include value="../personalDetails.jsp"/>
        </table>
        <table class="width-100">
            <tr id="nominatedSuccessor">
                <td><s:label value="%{getText('nominated_successor.label')}"/></td>
                <td colspan="3"><s:textfield id="successor" name="alienation.successor" cssClass="width-595-px"
                                             rows="1"/></td>
            </tr>
        </table>
    </div>
    <div id="occupier-details">
        <table class="width-100">
            <s:include value="../encroacherDetails.jsp"/>
        </table>
    </div>
</div>
<s:hidden name="alienation.id"/>
<s:hidden name="alienation.holder.id"/>
<s:hidden name="alienation.holder.contacts.id"/>
<s:hidden name="alienation.holder.holderType" value="1"/>
<s:hidden id="pls_enter_reference_no" value="%{getText('pls_enter_reference_no')}"/>

<%--<s:hidden id="ViolatedOrNot" name="alienation.conditionsViolatedOrNot"/>--%>
